<template>
	<div class="app-container">
		<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
			<el-form-item label="隐患名称">
				<el-input v-model="queryParams.hiddenInventoryName" placeholder="请输入隐患名称" clearable
					@keyup.enter.native="handleQuery" />
			</el-form-item>
			<!--
         <el-form-item label="登记人">
            <el-input v-model="queryParams.hiddenCheckUser" placeholder="请输入登记人" clearable
               @keyup.enter.native="handleQuery" />
         </el-form-item>
         -->
			<el-form-item label="隐患来源">
				<el-input v-model="queryParams.hiddenSource" placeholder="请输入隐患来源" clearable
					@keyup.enter.native="handleQuery" />
			</el-form-item>
			<el-form-item label="隐患进度">
				<el-select v-model="queryParams.hiddenProgress" placeholder="请选择检查类型" clearable>
					<el-option v-for="(value, key) in ['待审核', '待整改', '待复核', '已驳回', '已超时', '已完成']" :key="value"
						:label="value" :value="value" />
				</el-select>
			</el-form-item>
			<el-form-item label="是否上传" prop="checkLevel">
				<el-select v-model="queryParams.governUpload" placeholder="请选择检查类型" clearable>
					<el-option v-for="(option, key) in [{ key: 0, label: '未上传' }, { key: 1, label: '已上传' }]" :key="key"
						:label="option.label" :value="option.key" />
				</el-select>
			</el-form-item>
			<el-form-item>
				<el-button type="primary" icon="el-icon-search" size="small"
					v-hasPermi="['check:governHiddenInventory:query']" @click="handleQuery">搜索</el-button>
				<el-button icon="el-icon-refresh" size="small" @click="resetQuery">重置</el-button>
			</el-form-item>
		</el-form>

		<el-card class="card-box">
			<template #header>
				<span style="display: flex; justify-content: flex-end;">
					<el-button type="primary" icon="upload" size="small" :disabled="multiple"
						v-hasPermi="['check:governHiddenInventory:add']" @click="handleUpload">上传</el-button>
				</span>
			</template>

			<el-table v-loading="loading" :data="governHiddenInventoryList" @selection-change="handleSelectionChange">
				<el-table-column type="selection" width="55" align="center" fixed="left" />
				<el-table-column label="序号" width="55" type="index" align="center" prop="id" fixed="left" />
				<el-table-column label="隐患名称" align="center" prop="hiddenInventoryName" width="250"
					:show-overflow-tooltip="true" />
				<el-table-column label="隐患来源" align="center" prop="hiddenSource" width="120" />
				<el-table-column label="所属装置" align="center" prop="deviceName" />
				<el-table-column label="隐患级别" align="center" prop="hiddenLevel" />
				<el-table-column label="隐患类型" align="center" prop="hiddenCheckType" />
				<el-table-column label="隐患进度" align="center" prop="hiddenProgress" />
				<el-table-column label="审批状态" align="center" prop="governConfirm">
					<template v-slot="scope">
						{{ scope.row.governConfirm === 0 ? '待审批' : '已通过' }}
					</template>
				</el-table-column>
				<el-table-column label="是否上传" align="center" prop="governUpload">
					<template v-slot="scope">
						{{ scope.row.governUpload === 0 ? '未上传' : '已上传' }}
					</template>
				</el-table-column>

				<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="270"
					fixed="right">
					<template #default="scope">
						<el-button type="text" icon="folder-checked" @click="handleFinished(scope.row)"
							:disabled="scope.row.governConfirm === 1"
							v-hasPermi="['check:governHiddenInventory:pass']">通过</el-button>
						<el-button type="text" icon="folder-delete" @click="handleRejecting(scope.row)"
							v-hasPermi="['check:governHiddenInventory:reject']">驳回</el-button>
						<el-button type="text" icon="edit" @click="handleEdit(scope.row)"
							v-hasPermi="['check:governHiddenInventory:edit']">编辑</el-button>
						<el-button type="text" icon="view" @click="handleView(scope.row)"
							v-hasPermi="['check:governHiddenInventory:query']">详情</el-button>
					</template>
				</el-table-column>
			</el-table>
		</el-card>
		<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum"
			v-model:limit="queryParams.pageSize" @pagination="getList" />

		<!-- 隐患录入对话框 -->
		<el-dialog :title="title" v-model="hiddenOpen" width="55%" append-to-body>
			<el-form ref="addHidden" :model="formH" :rules="rules" label-width="150px" :disabled=!isEdit
				style="margin-right: 30px">
				<el-divider content-position="left">登记信息</el-divider>
				<el-row v-if="false">
					<el-col :span="12">
						<el-form-item label="登记人">
							<el-input v-model="formH.registerUserName" />
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="登记时间">
							<el-date-picker v-model="formH.governCreateDate" type="date" placeholder="选择日期"
								style="width: 100%" />
						</el-form-item>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="12">
						<el-form-item label="隐患名称:" prop="hiddenInventoryName">
							<el-input v-model="formH.hiddenInventoryName" placeholder="请输入隐患名称" />
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="隐患来源:" prop="hiddenSource">
							<el-select v-model="formH.hiddenSource" placeholder="请选择隐患来源" clearable
								style="width: 100%;">
								<el-option v-for="value in sourceList" :key="value" :label="value" :value="value" />
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="隐患分类:" prop="hiddenType">
							<el-select v-model="formH.hiddenType" placeholder="请选择隐患分类" clearable style="width: 100%;">
								<el-option v-for="value in hiddenTypeList" :key="value" :label="value" :value="value" />
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="隐患等级:" prop="hiddenLevel">
							<el-select v-model="formH.hiddenLevel" placeholder="请选择隐患等级" clearable style="width: 100%;">
								<el-option v-for="value in hiddenLevelList" :key="value" :label="value"
									:value="value" />
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="所属装置:" label-position="right">
							<el-select v-model="formH.deviceName" placeholder="请选择所属装置" clearable style="width: 100%;"
								@change="fChangeDevice">
								<el-option v-for="device in deviceList" :key="device.id" :label="device.deviceName"
									:value="device" />
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="所属部门:" label-position="right">
							<TreeSelect v-model="formH.deptName" :options="deptNameList" placeholder="请选择所属部门"
								@change="changeDept" />
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="排查级别:">
							<el-select v-model="formH.checkLevel" placeholder="请选择排查级别" clearable style="width: 100%;">
								<el-option v-for="value in checkList" :key="value" :label="value" :value="value" />
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="排查类型:" prop="hiddenCheckType">
							<el-select v-model="formH.hiddenCheckType" placeholder="请选择排查类型" clearable
								style="width: 100%;">
								<el-option v-for="value in taskTypeList" :key="value" :label="value" :value="value" />
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="危害类型:" prop="harmType">
							<el-select v-model="formH.harmType" placeholder="请选择危害类型" clearable style="width: 100%;">
								<el-option v-for="value in WeiHaiTypeList" :key="value" :label="value" :value="value" />
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="治理资金:" label-position="right">
							<el-input v-model="formH.hiddenManagingFunds" placeholder="请输入治理资金" />
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="隐患治理类型:" prop="dangerManageType">
							<el-select v-model="formH.dangerManageType" placeholder="请选择隐患治理类型" clearable
								style="width: 100%;">
								<el-option v-for="value in ZhiLiTypeList" :key="value" :label="value" :value="value" />
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="隐患治理期限:" prop="rectificationEndTime">
							<el-date-picker v-model="formH.rectificationEndTime" type="date" placeholder="选择日期"
								style="width: 100%;" />
						</el-form-item>
					</el-col>
				</el-row>
				<el-form-item label="隐患描述:" prop="hiddenInfo">
					<el-input v-model="formH.hiddenInfo" type="textarea" :rows="3" placeholder="请输入隐患描述" />
				</el-form-item>
				<el-form-item label="形成原因:">
					<el-input v-model="formH.hiddenEntryBasis" type="textarea" :rows="3" placeholder="请输入形成原因" />
				</el-form-item>
				<el-form-item label="整改措施:">
					<el-input v-model="formH.hiddenRectificationMeasures" type="textarea" :rows="3"
						placeholder="请输入整改措施" />
				</el-form-item>
				<!--     <el-form-item label="隐患图片:">
               <el-image style="width: 100px; height: 100px" :src="formH.hiddenFileUrl" />
            </el-form-item> -->
				<el-form-item label="检查项:">
					<el-select v-model="formH.governCheckTaskItemId" placeholder="请选择检查项" clearable style="width: 100%;"
						@change="governCheckChanged">
						<el-option v-for="item in governCheckNameList" style="width:1000px;" :key="item.id"
							:label="item.governCheckName + item.governCheckContent"
							:value="item.governCheckTaskItemId" />
					</el-select>
				</el-form-item>
				<el-form-item label="检查依据:">
					<el-input v-model="formH.governCheckBasis" type="textarea" :rows="3" placeholder="请输入检查依据"
						:disabled="true" />
				</el-form-item>
				<el-form-item label="检查方式:">
					<el-input v-model="formH.governCheckWay" type="textarea" :rows="3" placeholder="请输入检查方式"
						:disabled="true" />
				</el-form-item>
				<el-form-item label="适用场合:">
					<el-input v-model="formH.governApplicablePlace" type="textarea" :rows="3" placeholder="请输入适用场合"
						:disabled="true" />
				</el-form-item>

				<el-row>
					<el-col :span="12">
						<el-form-item label="扣分:">
							<el-select v-model="formH.governCheckTaskItemScoreId" placeholder="请选择扣分" clearable
								style="width: 100%;">
								<el-option v-for="item in deductPointList" :key="item.id"
									:label="item.governDeductPoint" :value="item.governCheckTaskItemScoreId" />
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="否决项:">
							<el-select v-model="formH.governIsReject" placeholder="请选择否决项" clearable
								style="width: 100%;">
								<el-option v-for="item in [{ id: 1, value: '是' }, { id: 0, value: '否' }]" :key="item.id"
									:label="item.value" :value="item.id" />
							</el-select>
						</el-form-item>
					</el-col>
				</el-row>
				<el-form-item label="扣分说明:">
					<el-input v-model="formH.governDeductIllustrate" type="textarea" :rows="3" placeholder="请输入扣分说明"
						:disabled="true" />
				</el-form-item>
				<el-row>
					<el-col :span="12">
						<el-form-item label="罚款金额:">
							<el-input v-model="formH.hiddenCheckPay" placeholder="请输入罚款金额" />
						</el-form-item>
					</el-col>
				</el-row>

				<el-form-item label="文件上传:" prop="fileId">
					<FileUpload :limit="1" :fileSize="30" v-model="files"></FileUpload>
				</el-form-item>

				<el-row>
					<el-col :span="12">
						<el-form-item label="复核人:" label-position="right" prop="reviewUserName">
							<el-input v-model="formH.reviewUserName" readonly placeholder="请选择复核人"
								@click="onInnerOpen('reviewUser')" />
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="整改人:" label-position="right" prop="rectificationUserName">
							<el-input v-model="formH.rectificationUserName" readonly placeholder="请选择整改人"
								@click="onInnerOpen('rectificationUser')" />
						</el-form-item>
					</el-col>
				</el-row>


				<!-- <el-divider content-position="left">整改情况</el-divider>
            <el-row>
               <el-col :span="12">
                  <el-form-item label="整改人:" label-position="right" prop="rectificationUserName">
                     <el-input v-model="formH.rectificationUserName" readonly placeholder="请选择整改人"
                        @click="onInnerOpen('rectificationUser')" />
                  </el-form-item>
               </el-col>
               <el-col :span="12">
                  <el-form-item label="整改时间:">
                     <el-date-picker v-model="formH.hiddenCompleteTime" type="date" placeholder="选择日期"
                        style="width: 100%" />
                  </el-form-item>
               </el-col>
               <el-col>
                  <el-form-item label="整改情况:">
                     <el-input v-model="formH.hiddenCompleteInfo" type="textarea" :rows="3" placeholder="请输入整改情况" />
                  </el-form-item>
               </el-col>
               <el-col :span="12">
                  <el-form-item label="整改图片:">
                     <el-image style="width: 100px; height: 100px" :src="formH.completeHiddenFileUrl" />
                  </el-form-item>
               </el-col>
            </el-row>
            <el-divider content-position="left">复核情况</el-divider>
            <el-row>
               <el-col :span="12">
                  <el-form-item label="复核人:" label-position="right" prop="reviewUserName">
                     <el-input v-model="formH.reviewUserName" readonly placeholder="请选择复核人"
                        @click="onInnerOpen('reviewUser')" />
                  </el-form-item>
               </el-col>
               <el-col :span="12">
                  <el-form-item label="复核时间:" style="width: 100%">
                     <el-date-picker v-model="formH.hiddenReviewTime" type="date" placeholder="选择日期"
                        style="width: 100%" />
                  </el-form-item>
               </el-col>
               <el-col>
                  <el-form-item label="复核情况:">
                     <el-input v-model="formH.hiddenReviewInfo" type="textarea" :rows="3" placeholder="请输入复核情况" />
                  </el-form-item>
               </el-col>
            </el-row> -->
				<TableSelect ref="userTableSelect" :queryApi="listUser" :options="[]" :rowKey="'userId'"
					rowLabel="nickName" @onConfirm="onUserConfirm" rowLabelText="用户昵称" :maxNum="1">
					<template #formSlot="{ handleQuery, filterForm }">
						<el-col :span="8">
							<el-form-item label="部门名称">
								<el-input size="small" @change="handleQuery" v-model="filterForm.deptName" clearable
									style="width: 100%" @keyup.enter="handleQuery" />
							</el-form-item>
						</el-col>
						<el-col :span="8">
							<el-form-item label="用户名称">
								<el-input size="small" @change="handleQuery" v-model="filterForm.userName" clearable
									style="width: 100%" @keyup.enter="handleQuery" />
							</el-form-item>
						</el-col>
					</template>
					<template #tableSlot>
						<el-table-column label="部门" align="center" key="deptName" prop="dept.deptName" />
						<el-table-column label="用户名称" align="center" key="userName" prop="userName" />
						<el-table-column label="用户昵称" align="center" key="nickName" prop="nickName" />
					</template>
				</TableSelect>
			</el-form>
			<template #footer>
				<div class="dialog-footer">
					<el-button type="primary" @click="submitHiddenForm" v-if="isEdit">保存并提交</el-button>
				</div>
			</template>
		</el-dialog>

	</div>
</template>

<script setup name="GovernHiddenInventory">
	import {
		listGovernHiddenInventory,
		uploadGovernHiddenInventory,
		confirmGovernHiddenInventory,
		getGovernHiddenInventory,
		delGovernHiddenInventory
	} from "@/api/check/governHiddenInventory";
	import {
		getCheckType,
		getDeviceLevel,
		getCheckLevel,
		getHiddenType,
		getHiddenLevel,
		getHiddenSource,
		getWeiHaiType,
		getZhiLiType,
		governCheckTaskItemId,
		putGovernHiddenInventory,
		governCheckTaskItem,
	} from "@/api/check/governCheckTaskInfo";
	import {
		deptTreeSelect,
		listUser
	} from "@/api/system/user";
	import TableSelect from "@/components/tableSelect/index";
	// 文件上传组件
	import FileUpload from "@/components/FileUpload";
	const files = ref([]);

	const {
		proxy
	} = getCurrentInstance();

	// 表单数据
	const governHiddenInventoryList = ref([]);
	const loading = ref(true);
	const showSearch = ref(true);
	const ids = ref([]);
	const single = ref(true);
	const multiple = ref(true);
	const total = ref(0);

	// 隐患编辑对话框
	const hiddenOpen = ref(false);
	const isEdit = ref(true);
	const title = ref("");


	// 隐患录入模态框
	const deptNameList = ref([]);
	const deviceList = ref([]);
	const sourceList = ref([]);
	const checkList = ref([]);
	const hiddenLevelList = ref([]);
	const hiddenTypeList = ref([]);
	const WeiHaiTypeList = ref([]);
	const ZhiLiTypeList = ref([]);
	const taskTypeList = ref([]);
	const userTableSelect = ref();
	const deductPointList = ref([]);
	const governCheckNameList = ref([]);
	const userType = ref("");
	const changeDept = (val, label) => {
		formH.value.deptName = label;
		formH.value.deptId = val;
	};
	const onInnerOpen = (type) => {
		userType.value = type;
		const {
			rectificationUserId,
			rectificationUserName,
			reviewUserId,
			reviewUserName,
		} = formH.value;
		let values = (rectificationUserId && rectificationUserId.split(",")) || [];
		let names = (rectificationUserName && rectificationUserName.split(",")) || [];
		if (type == "reviewUser") {
			values = (reviewUserId && reviewUserId.split(",")) || [];
			names = (reviewUserName && reviewUserName.split(",")) || [];
		}
		userTableSelect.value.open(
			values.map((item, index) => ({
				value: values[index],
				label: names[index],
			}))
		);
	};
	const onUserConfirm = (data) => {
		const values = data.map((item) => item.value);
		const names = data.map((item) => item.label);
		if (userType.value == "reviewUser") {
			formH.value.reviewUserId = values.join(",");
			formH.value.reviewUserName = names.join(",");
		} else {
			formH.value.rectificationUserId = values.join(",");
			formH.value.rectificationUserName = names.join(",");
		}
	};

	const data = reactive({
		formH: {
			taskTypeList: [],
			deptNameList: [],
			deviceList: [],
			sourceList: [],
			checkList: [],
			hiddenLevelList: [],
			hiddenTypeList: [],
			WeiHaiTypeList: [],
			ZhiLiTypeList: []

		},
		queryParams: {
			pageNum: 1,
			pageSize: 10,
			governCheckTaskName: undefined,
			governTaskTypeName: undefined,
			governCheckTaskTypeName: undefined
		},
		rules: {
			hiddenInventoryName: [{
				required: true,
				message: "隐患名称不能为空",
				trigger: "blur"
			}],
			hiddenSource: [{
				required: true,
				message: "隐患来源不能为空",
				trigger: "blur"
			}],
			hiddenType: [{
				required: true,
				message: "隐患分类不能为空",
				trigger: "blur"
			}],
			hiddenLevel: [{
				required: true,
				message: "隐患登记不能为空",
				trigger: "blur"
			}],
			hiddenCheckType: [{
				required: true,
				message: "排查类型不能为空",
				trigger: "blur"
			}],
			harmType: [{
				required: true,
				message: "危害类型不能为空",
				trigger: "blur"
			}],
			dangerManageType: [{
				required: true,
				message: "隐患治理类型不能为空",
				trigger: "blur"
			}],
			rectificationEndTime: [{
				required: true,
				message: "隐患治理期限不能为空",
				trigger: "blur"
			}],
			hiddenInfo: [{
				required: true,
				message: "隐患描述不能为空",
				trigger: "blur"
			}],
			rectificationUserName: [{
				required: true,
				message: "整改人不能为空",
				trigger: "blur"
			}],
			reviewUserName: [{
				required: true,
				message: "复核人不能为空",
				trigger: "blur"
			}],
		}
	});

	const {
		queryParams,
		formH,
		rules
	} = toRefs(data);

	const fChangeDevice = (e) => {
		formH.value.deviceId = e.id;
		formH.value.deviceName = e.deviceName;
	}

	/** 查询参数列表 */
	function getList() {
		loading.value = true;
		listGovernHiddenInventory(queryParams.value).then(response => {
			governHiddenInventoryList.value = response.rows;
			total.value = response.total;
			loading.value = false;
		});
	}
	/** 上传 */
	function handleUpload() {
		loading.value = true;
		const inventoryIds = ids.value;
		// console.log(inventoryIds);
		proxy.$modal.confirm('是否确认上传参数编号为"' + inventoryIds + '"的数据项？').then(function() {
			return uploadGovernHiddenInventory({
				hiddenInventoryIds: inventoryIds
			});
		}).then(() => {
			getList();
			proxy.$modal.msgSuccess("上报成功");
			loading.value = false;
		}).catch(() => {
			loading.value = false;
		});

	}
	/** 确认 */
	function handleFinished(row) {
		proxy.$modal.confirm('确认通过隐患名称："' + row.hiddenInventoryName + '"的数据项？').then(function() {
			loading.value = true;
			const params = {
				hiddenInventoryId: row.hiddenInventoryId,
				governConfirm: 1
			};
			confirmGovernHiddenInventory(params).then(response => {
				proxy.$modal.msgSuccess("确认成功");
				getList();
				loading.value = false;
			});
		}).catch(() => {
			loading.value = false;
		});
	}
	/** 驳回 */
	function handleRejecting(row) {
		proxy.$modal.confirm('确认驳回隐患名称："' + row.hiddenInventoryName + '"的数据项？').then(function() {
			loading.value = true;
			delGovernHiddenInventory({
				id: row.hiddenInventoryId
			}).then(response => {
				proxy.$modal.msgSuccess("驳回成功");
				getList();
				loading.value = false;
			});
		}).catch(() => {
			loading.value = false;
		});
	}
	/** 编辑 */
	function handleEdit(row) {
		resetHidden();
		hiddenOpen.value = true;
		isEdit.value = true;
		title.value = "隐患编辑";

		initHidden(row);
	}

	/** 详情 */
	function handleView(row) {
		resetHidden();
		hiddenOpen.value = true;
		isEdit.value = false;
		title.value = "隐患详情";

		initHidden(row)

	}
	/** 隐患录入表单初始化*/
	function initHidden(row) {
		getGovernHiddenInventory(row.hiddenInventoryId).then(response => {
			// console.log(response.data);
			formH.value = response.data;
			if (response.data.hiddenFileId) {
				files.value = [{
					name: response.data.hiddenFileName,
					id: response.data.hiddenFileId,
					url: response.data.hiddenFileUrl,
				}, ];
			} else {
				files.value = [];
			}

		});
		formH.value.hiddenSource = '专项检查';
		formH.value.registerUserName = JSON.parse(localStorage.getItem("USER_INFO")).nickName;
		formH.value.governCreateDate = new Date();

		const governCheckTaskId = row.governCheckTaskId;
		governCheckTaskItem({
			governCheckTaskId: governCheckTaskId
		}).then(response => {
			governCheckNameList.value = response.rows;
			const foundItem = governCheckNameList.value.find(item => item.governCheckTaskItemId === row
				.governCheckTaskItemId);
			// console.log(row.governCheckTaskItemId);
			if (!foundItem) {
				return;
			}

			formH.value.governCheckBasis = foundItem.governCheckBasis;
			formH.value.governCheckWay = foundItem.governCheckWay;
			formH.value.governApplicablePlace = foundItem.governApplicablePlace;
			governCheckChanged(row.governCheckTaskItemId);
			formH.value.governTaskInfoId = row.governTaskInfoId;
			formH.value.governCheckTaskId = governCheckTaskId;
			formH.value.governCheckTaskItemId = row.governCheckTaskItemId;
		});
	}

	/** 检查项改变事件 */
	function governCheckChanged(id) {
		deductPointList.value = [];
		governCheckTaskItemId(id).then(response => {
			if (response.data) {
				deductPointList.value = response.data;
				// 设置默认值
				formH.value.governCheckTaskItemScoreId = response?.data[0]?.governCheckTaskItemScoreId;
				formH.value.governDeductIllustrate = response?.data[0]?.governDeductIllustrate;
				formH.value.governDeductPoint = response?.data[0]?.governDeductPoint;
			} else {
				formH.value.governCheckTaskItemScoreId = undefined;
				formH.value.governDeductIllustrate = undefined;
				formH.value.governDeductPoint = undefined;
			}
		});
	}

	/** 隐患录入表单重置 */
	function resetHidden() {
		formH.value = {};
		proxy.resetForm("addHidden");
	}



	/** 查询检验类型列表 */
	function getDicList() {
		getCheckType().then(response => {
			taskTypeList.value = response.data;
		});
		deptTreeSelect().then((response) => {
			deptNameList.value = response.data;
		});
		getDeviceLevel().then(response => {
			deviceList.value = response.data;
		});
		getHiddenSource().then(response => {
			sourceList.value = response.data;
		});
		getCheckLevel().then(response => {
			checkList.value = response.data;
		});
		getHiddenLevel().then(response => {
			hiddenLevelList.value = response.data;
		});
		getHiddenType().then(response => {
			hiddenTypeList.value = response.data;
		});
		getWeiHaiType().then(response => {
			WeiHaiTypeList.value = response.data;
		});
		getZhiLiType().then(response => {
			ZhiLiTypeList.value = response.data;
		});
	}

	/** 多选框选中数据 */
	function handleSelectionChange(selection) {
		ids.value = selection.map(item => item.hiddenInventoryId);
		single.value = selection.length != 1;
		multiple.value = !selection.length;
	}


	/** 搜索按钮操作 */
	function handleQuery() {
		queryParams.value.pageNum = 1;
		getList();
	}
	/** 重置按钮操作 */
	function resetQuery() {
		proxy.resetForm("queryRef");
		handleQuery();
	}

	/** 隐患录入提交按钮 */
	function submitHiddenForm() {
		proxy.$refs["addHidden"].validate(valid => {
			if (valid) {
				putGovernHiddenInventory(formH.value).then(response => {
					proxy.$modal.msgSuccess("提交成功！");
					hiddenOpen.value = false;
					getList();
				});
			}
		});
	}

	watch(
		() => files,
		(newData) => {
			if (newData.value.length === 0) {
				formH.value.hiddenFileId = "";
				formH.value.hiddenFileUrl = "";
				formH.value.hiddenFileName = "";
			} else {
				formH.value.hiddenFileName = newData.value[0].name;
				formH.value.hiddenFileId = newData.value[0].id;
				formH.value.hiddenFileUrl = newData.value[0].url;
			}
		}, {
			deep: true,
		}
	);

	getList();
	getDicList();
</script>